import QtQuick
import QtQuick.Controls
import Tool 1.0
ApplicationWindow {
    // Connections {
    //     target: Tool
    //     function onJoctoqml(jsonObj){
    //         // handleJsonObject(jsonObj)
    //         // var json=JSON.parse(jsonObj)
    //         console.log(jsonObj["code"])
    //     }
    // }




    Material.accent: Material.Blue
    property color color_KLEINBLU: "#002FA7"
    property color color_DOQIBLU: "#1e90ff"
    property color color_MaterialBlue: "#2196F3"
    width: 1200
    height: 900
    visible: true
    title: qsTr("CodeNest")





    KPopUp{
        id:main_kpopup
        anchors.centerIn: parent
    }




    header:ToolBar{
        // Material.accent: color_DOQIBLU
        Rectangle{
            anchors.fill: parent
            color:color_MaterialBlue
            Image {

                source: "qrc:/img/headerCodeNest.png"
                height: parent.height
                anchors.centerIn: parent
                width: height*3.2
                mipmap: true
                smooth: true
                fillMode:Image.PreserveAspectCrop
            }



            Button {
                Material.accent: Material.Blue
                highlighted: true
                Material.roundedScale: Material.SmallScale
                anchors.rightMargin: 5
                height: parent.height
                anchors.right: parent.right
                width:height
                anchors.verticalCenter: parent.verticalCenter
                Image{
                    width: parent.width*0.6
                    height:width
                    anchors.centerIn: parent
                    source: "qrc:/ICON/icon/SETUP2.png"
                    mipmap: true
                    smooth: true
                    fillMode:Image.PreserveAspectCrop
                }
            }


            Button {
                Material.accent: Material.Blue
                highlighted: true
                Material.roundedScale: Material.SmallScale
                height: parent.height
                width:height
                anchors.left: parent.left
                anchors.leftMargin: 5
                anchors.verticalCenter: parent.verticalCenter
                Image{
                    width: parent.width*0.6
                    height:width
                    anchors.centerIn: parent
                    source: "qrc:/ICON/icon/MINE2.png"
                    mipmap: true
                    smooth: true
                    fillMode:Image.PreserveAspectCrop
                }

                KUserPage{
                    id:userPage
                    // anchors.horizontalCenter: parent.horizontalCenter
                }


                onClicked: {
                    userPage.isVisible=!(userPage.isVisible)
                }
            }

        }


    }

    SplitView{
        anchors.fill: parent

        handle: Rectangle{
            implicitWidth: 4
            implicitHeight: parent.height
            color: "grey"
        }
        Item {
            implicitWidth: parent.width*1/3
            implicitHeight: parent.height
            SplitView.minimumWidth: 100
            Column{
                anchors.fill: parent
                spacing:5
                Rectangle{//添加等操作
                    implicitWidth : parent.width
                    implicitHeight: 30
                    color: color_MaterialBlue
                    // border.color:"lightgrey"
                    // border.width:1
                    Row{
                        spacing:3
                        anchors.fill: parent
                        Rectangle{
                            color: "transparent"
                            width: 1
                            height:parent.height
                        }
                        Component{
                            id:koperationbutton_kaddpage_comp_main
                            // property string tabbarname:"创建"
                            KAddPage{
                                id:koperationbutton_kaddpage
                            }
                        }
                        Image{
                            height:parent.height*0.8
                            anchors.verticalCenter: parent.verticalCenter
                            width: height
                            source:"qrc:/ICON/icon/APPEND3.png"
                            mipmap: true
                            smooth: true
                            MouseArea{
                                anchors.fill: parent
                                onClicked: {
                                    var properties_mountCollectoin = {
                                        type: "MountCollectionCreated",
                                        names:"",
                                        tabbarname: "创建挂载控制集",
                                        listmodel:kCodeNestTreeView_main.kCodeNestTreeView_ListModelAlias
                                        /*kCodeNestTreeView_ListModel*/
                                    };
                                    var mountCollectionPage= koperationbutton_kaddpage_comp_main.createObject(parent,properties_mountCollectoin)
                                    main_ktabbarview.appendPage2(mountCollectionPage,"");
                                }

                            }

                        }

                    }
                }
                Rectangle{//左侧搜索框
                    implicitWidth : parent.width
                    implicitHeight: 45
                    // color: color_MaterialBlue
                    Row{
                        width: parent.width*0.9
                        height: parent.height
                        anchors.centerIn: parent
                        spacing:3
                        TextField{
                            Material.accent: Material.Blue
                            height: parent.height*0.88
                            width: parent.width*0.7
                            anchors.verticalCenter: parent.verticalCenter
                        }

                        Button{
                            Material.accent: Material.Blue
                            highlighted: true
                            height: parent.height
                            width: parent.width*0.28
                            Material.roundedScale: Material.SmallScale
                            anchors.verticalCenter: parent.verticalCenter
                            text:"搜 索"
                        }
                    }

                }
                ScrollView{//
                    anchors.horizontalCenter: parent.horizontalCenter
                    implicitWidth: parent.width-10
                    implicitHeight: parent.height-10-45-30-10
                    KCodeNestTreeView{
                        id:kCodeNestTreeView_main
                        anchors.fill: parent



                    }
                    // Rectangle{
                    //     anchors.fill: parent
                    //     color: "yellow"
                    // }


                }


            }

        }
        Item {

            implicitWidth: parent.width*2/3-4
            implicitHeight: parent.height
            SplitView.minimumWidth: 100
            KTabBarView{
                id:main_ktabbarview
                anchors.fill: parent
                Component.onCompleted: {
                    appendPage(startWelcome)
                    // appendPage(startWelcome2)
                    // appendPage(startWelcome3)

                }

                WelcomePage{
                    id:startWelcome
                }

            }


        }

    }

}
